#ifndef ClientObj_H_
#define ClientObj_H_

#include "remoting/remote_client.h"
#include "basic/thread_object.h"

class CremotingTest2Dlg;
typedef void ( * ThreadFunc_t ) ( void * );
class ClientObject : public HT::ThreadObject
{
public:
	ClientObject(int id, string ip, int port, HANDLE evt, HANDLE exitEvt, CremotingTest2Dlg* dlg)
	{
		mID = id;
		strIP = ip;
		nPort = port;
		mEvent = evt;
		exitSemaphore = exitEvt;
		mFunc = NULL;
		mArg = NULL;
		okCount = 0;
		failCount = 0;
		TotalCount = 0;
		pDlg = dlg;
		nRecvEventCount = 0;
	}

	virtual ~ClientObject()
	{
	}

private:
	RemoteClient pClient;
	int nPort;
	string strIP;

	int mID;
	HANDLE exitSemaphore;
	HANDLE mEvent;
	HT::Mutex mMutex;
	ThreadFunc_t mFunc;
	void * mArg;

public:				//TestArg
	CremotingTest2Dlg* pDlg;
	//Test Connect Limit
	int nConnectTime;
	
	//Test EchoData
	Amf::AmfArrayPtr pParam;
	LPCWSTR strClassName;
	LPCWSTR strFunc;
	int TotalCount;
	int okCount;
	int failCount;
	
	//Event Test
	int nRecvEventCount;
	LPCWSTR strListenEvent;
	RpcCB* pCB;

	string GetServerIP() { return strIP; }
	int GetServerPort() { return nPort; }
	int GetThreadNO()	{ return mID; }
	RemoteClient * GetCurrClient() { return &pClient; }

protected:
	virtual void OnExit();
	virtual void Run();

public:
	void Execute(ThreadFunc_t fun, void * arg)
	{
		HT_CS(mMutex);
		mFunc = fun;
		mArg = arg;
	}
};

#endif